package com.ListDemo.Test;

import java.util.ArrayList;
import java.util.LinkedList;

public class ListDemo_使用ArrayList和LinkedList完成字符串遍历 {
    public static void main(String[] args) {
        //创建结合对象
        ArrayList<String> alist = new ArrayList<String>();

        //添加元素
        alist.add("hello");
        alist.add("world");
        alist.add("java");

        //增强for遍历
        for (String s:alist){
            System.out.println(s);
        }

        System.out.println("--------");

        LinkedList<String> linkedList = new LinkedList<String>();

        linkedList.add("hello");
        linkedList.add("world");
        linkedList.add("java");

        for (String s : linkedList){
            System.out.println(s);
        }

    }
}
